package leetcode.code0605;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution implements IDebug {

	public boolean canPlaceFlowers(int[] flowerbed, int n) {
		int len = flowerbed.length;
		for (int i = 0; i < len && n > 0; i++) {
			if (flowerbed[i] == 0) {
				if ((i == 0 || flowerbed[i - 1] == 0) && (i == len - 1 || flowerbed[i + 1] == 0)) {
					n -= 1;
					flowerbed[i] = 1;
				}
			}
		}
		return n == 0;
	}

	@Override
	public void debug1() {
		HelpDebug.compare(false, this.canPlaceFlowers(HelpDebug.str2array3("[1,0,0,0,0,1]"), 2));

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
